package com.ecoolex.ying.space.ws;

import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.common.pojo.Sorting;
import com.ecoolex.ying.space.core.manager.*;
import com.ecoolex.ying.space.entity.*;
import com.ecoolex.ying.space.pojo.*;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class DesignerProjectServiceImpl implements DesignerProjectService {

    @Autowired
    private DesignerProjectManager designerProjectManager;

    @Override
    public DesignerProject createProject(Integer userId, EditDesignerProjectDTO add, String createUser) {
        return designerProjectManager.create(userId, add, createUser);
    }

    @Override
    public DesignerProject copyProject(Integer userId, DesignerProject project, String createUser) {
        return designerProjectManager.copy(userId, project, createUser);
    }

    @Override
    public void updateProject(Integer userId, Integer projectId, EditDesignerProjectDTO edit, String updateUser) {
        designerProjectManager.update(userId, projectId, edit, updateUser);
    }

    @Override
    public void deleteProject(Integer userId, Integer projectId, String updateUser) {
        designerProjectManager.delete(userId, projectId, updateUser);
    }

    @Override
    public DesignerProject getProjectByUserIdAndId(Integer userId, Integer projectId) {
        return designerProjectManager.getByUserIdAndId(userId, projectId);
    }

    @Override
    public Pagination<DesignerProject> queryProjectByUserId(QueryDesignerProjectByUserDTO query, Integer userId, Sorting[] sorts, Page page) {
        return designerProjectManager.queryByUserId(query, userId, sorts, page);
    }

    @Override
    public DesignerProject getProjectById(Integer projectId) {
        return designerProjectManager.getById(projectId);
    }

    @Override
    public Pagination<DesignerProject> queryProject(QueryDesignerProjectDTO query, Sorting[] sorts, Page page) {
        return designerProjectManager.query(query, sorts, page);
    }

    @Autowired
    private DesignerProjectAttributeManager designerProjectAttributeManager;

    @Override
    public void updateAttribute(Integer userId, Integer projectId, EditDesignerProjectAttributeDTO edit, String updateUser) {
        designerProjectAttributeManager.update(userId, projectId, edit, updateUser);
    }

    @Override
    public DesignerProjectAttribute getAttributeByProjectId(Integer projectId) {
        return designerProjectAttributeManager.getByProjectId(projectId);
    }

    @Autowired
    private DesignerProjectShareManager designerProjectShareManager;

    @Override
    public DesignerProjectShare resetShare(Integer userId, Integer projectId, Integer expirydateDay, String updateUser) {
        return designerProjectShareManager.reset(userId, projectId, expirydateDay, updateUser);
    }

    @Override
    public void clearShare(Integer userId, Integer projectId) {
        designerProjectShareManager.clear(userId, projectId);
    }

    @Override
    public DesignerProjectShare getShareByProjectId(Integer projectId) {
        return designerProjectShareManager.getByProjectId(projectId);
    }

    @Override
    public DesignerProjectShare getShareByShareId(String shareId) {
        return designerProjectShareManager.getByShareId(shareId);
    }

    @Override
    public DesignerProjectShare getShareByShareIdAndPassword(String shareId, String password) {
        return designerProjectShareManager.getByShareIdAndPassword(shareId, password);
    }

    @Autowired
    private DesignerProjectItemsManager designerProjectItemsManager;

    @Override
    public List<DesignerProjectPlanItemsDTO> updatePlanItems(DesignerProject project, List<EditDesignerProjectPlanItemsDTO> editList, String updateUser) {
        return designerProjectItemsManager.updatePlanItems(project, editList, updateUser);
    }

    @Override
    public List<DesignerProjectListingItemsDTO> updateListingItems(DesignerProject project, List<EditDesignerProjectListingItemsDTO> editList, String updateUser) {
        return designerProjectItemsManager.updateListingItems(project, editList, updateUser);
    }

    @Override
    public List<DesignerProjectItemsWithBLOBs> queryItemsByProjectId(Integer projectId) {
        return designerProjectItemsManager.queryByProjectId(projectId);
    }

    @Autowired
    private DesignerProjectItemsProductManager designerProjectItemsProductManager;

    @Override
    public List<DesignerProjectItemsProduct> queryItemsProductByItemsId(Integer itemsId) {
        return designerProjectItemsProductManager.queryByItemsId(itemsId);
    }

    @Autowired
    private DesignerProjectItemsProductCustomManager designerProjectItemsProductCustomManager;

    @Override
    public void updateItemsProductCustom(Integer userId, Integer itemsProductId, EditDesignerProjectItemsProductCustomDTO edit, String updateUser) {
        designerProjectItemsProductCustomManager.update(userId, itemsProductId, edit, updateUser);
    }

    @Override
    public DesignerProjectItemsProductCustom getItemsProductCustomByItemsProductId(Integer itemsProductId) {
        return designerProjectItemsProductCustomManager.getByItemsProductId(itemsProductId);
    }

    @Override
    public List<DesignerProjectItemsProductCustom> queryItemsProductCustomByItemsId(Integer itemsId) {
        return designerProjectItemsProductCustomManager.queryByItemsId(itemsId);
    }

    @Autowired
    private UserPickGoodsFavoriteManager userPickGoodsFavoriteManager;

    @Override
    public boolean existPickGoodsFavoriteByUserIdAndPickGoodsId(Integer userId, Integer pickGoodsId) {
        return userPickGoodsFavoriteManager.existByUserIdAndPickGoodsId(userId, pickGoodsId);
    }

    @Override
    public void addPickGoodsFavorite(Integer userId, Integer pickGoodsId, String createUser) {
        userPickGoodsFavoriteManager.add(userId, pickGoodsId, createUser);
    }

    @Override
    public void deletePickGoodsFavorite(Integer userId, Integer pickGoodsId, String updateUser) {
        userPickGoodsFavoriteManager.delete(userId, pickGoodsId, updateUser);
    }

    @Autowired
    private UserGoodsAttachmentDownloadTaskManager userGoodsAttachmentDownloadTaskManager;

    @Override
    public UserGoodsAttachmentDownloadTask createDownloadTaskByGoods(Integer userId, Goods goods, Integer goodsAttachmentType, String createUser) {
        return userGoodsAttachmentDownloadTaskManager.createByGoods(userId, goods, goodsAttachmentType, createUser);
    }

    @Override
    public UserGoodsAttachmentDownloadTask createDownloadTaskByProject(Integer userId, DesignerProject project, Integer goodsAttachmentType, String createUser) {
        return userGoodsAttachmentDownloadTaskManager.createByProject(userId, project, goodsAttachmentType, createUser);
    }

    @Override
    public void deleteDownloadTask(Integer userId, Integer taskId, String updateUser) {
        userGoodsAttachmentDownloadTaskManager.delete(userId, taskId, updateUser);
    }

    @Override
    public Pagination<UserGoodsAttachmentDownloadTask> queryDownloadTaskByUserId(Integer userId, QueryUserGoodsAttachmentDownloadTaskDTO query, Sorting[] sorts, Page page) {
        return userGoodsAttachmentDownloadTaskManager.queryByUserId(userId, query, sorts, page);
    }

    @Override
    public List<UserGoodsAttachmentDownloadTask> queryDownloadTaskByUserId(Integer userId, Integer maxTaskId, Integer size) {
        return userGoodsAttachmentDownloadTaskManager.queryByUserId(userId, maxTaskId, size);
    }

}
